#include "ifconfig.hpp"

#include <iostream>

using namespace std;

int main()
{
    char ifaces[MAXIFACES][IFNAMSIZ];
    char errorString[255];
    
    int numIFaces = PlateSpin::OperationsFramework::Controller::Utils::getIFaces(ifaces, errorString);
    if(numIFaces == 0)
    {
	    cout << "no network interface found" << endl;
    }
    
    string actingIpAddress;
    for(int i=0; i<numIFaces; i++)
    {
	struct interface ife;
	char buffer[256];
	memset(&ife, 0, sizeof(struct interface));
	strncpy(ife.ifname, ifaces[i], IFNAMSIZ);
	PlateSpin::OperationsFramework::Controller::Utils::getIFaceInfo(&ife, errorString);
	string ipaddr = inet_ntop(AF_INET, 
				  ife.addr.sa_data+sizeof(short), 
				  buffer,
				  sizeof(buffer));
    	
    cout << "found IP address: " << ipaddr << endl;
    }
    
    return 0;
    
}